/**********************************************************************************************************************
 * COPYRIGHT
 * -------------------------------------------------------------------------------------------------------------------
 * Copyright (c) iSOFT INFRASTRUCTURE SOFTWARE CO., LTD. This software is proprietary to
 * iSOFT INFRASTRUCTURE SOFTWARE CO., LTD., and all rights are reserved by iSOFT INFRASTRUCTURE SOFTWARE CO., LTD.
 * Without the express written permission of the company, no organization or individual may copy, install, trial,
 * distribute, or reverse engineer this software. For terms of use and further details, please refer to the End User
 * License Agreement (EULA) or contact us business@i-soft.com.cn for more assistance.
 *
 * This file contains code from EasyXMen, which is licensed under the LGPL-2.1. However, due to a special exception,
 * you are not required to comply with the provisions of section 6a of LGPL-2.1. Specifically, you may distribute
 * your software, including this file, under terms of your choice, including proprietary licenses, without needing to
 * provide the source code or object code as specified in section 6a. For more details, please refer to the project's
 * LICENSE and EXCEPTION files and the specific exception statement.
 * -------------------------------------------------------------------------------------------------------------------
 * FILE DESCRIPTION
 * -------------------------------------------------------------------------------------------------------------------
 *  @MCU                : S32K148
 *  @file               : Os_UserInf.c
 *  @license            : Evaliation
 *  @licenseExpiryDate  :
 *  @date               : 2024-10-21 10:37:16
 *  @customer           : EasyXMen User
 *  @toolVersion        : 2.0.18
 *********************************************************************************************************************/

/*=======[I N C L U D E S]====================================================*/
#include "Os.h"
#include "Arch_Extend.h"
#include "Arch_Processor.h"
/** DO NOT CHANGE THIS COMMENT!
 * <USERBLOCK User Includes>
 */
/* custom code.... */
#include "Gpt.h"
#include "Can_43_FLEXCAN.h"
#include "Mem_43_INFLS.h"
#include "MemAcc.h"
#include "EcuM.h"
#include "EcuM_Cbk.h"
#include "ComM.h"
#include "ComM_Gent.h"
#include "NvM.h"
#include "WdgM.h"
#include "Fee.h"
#include "Dem.h"
#include "MemIf_Types.h"
#include "SchM_Fee.h"
#include "SchM_MemAcc.h"
#include "SchM_CanSM.h"
#include "SchM_CanNm.h"
#include "SchM_NvM.h"
#include "SchM_Com.h"
#include "SchM_CanTp.h"
#include "SchM_Dcm.h"
#include "SchM_EcuM.h"
#include "SchM_BswM.h"
#include "SchM_Dem.h"
#include "SchM_WdgM.h"
#include "Crypto.h"
#include "Csm.h"
#include "sm2.h"
/** DO NOT CHANGE THIS COMMENT!
 * </USERBLOCK User Includes>
 */
/*=======[V E R S I O N   I N F O R M A T I O N]===============================*/
#define OS_USERAPP_C_AR_MAJOR_VERSION 19U
#define OS_USERAPP_C_AR_MINOR_VERSION 11U
#define OS_USERAPP_C_AR_PATCH_VERSION 0U
#define OS_USERAPP_C_SW_MAJOR_VERSION 2U
#define OS_USERAPP_C_SW_MINOR_VERSION 0U
#define OS_USERAPP_C_SW_PATCH_VERSION 0U

/*=======[V E R S I O N  C H E C K]===========================================*/
#if (OS_USERAPP_C_AR_MAJOR_VERSION != OS_CFG_H_AR_MAJOR_VERSION)
#error "Os_Userapp.c:Mismatch in Specification Major Version"
#endif
#if (OS_USERAPP_C_AR_MINOR_VERSION != OS_CFG_H_AR_MINOR_VERSION)
#error "Os_Userapp.c:Mismatch in Specification Minor Version"
#endif
#if (OS_USERAPP_C_AR_PATCH_VERSION != OS_CFG_H_AR_PATCH_VERSION)
#error "Os_Userapp.c:Mismatch in Specification Patch Version"
#endif
#if (OS_USERAPP_C_SW_MAJOR_VERSION != OS_CFG_H_SW_MAJOR_VERSION)
#error "Os_Userapp.c:Mismatch in Specification Major Version"
#endif
#if (OS_USERAPP_C_SW_MINOR_VERSION != OS_CFG_H_SW_MINOR_VERSION)
#error "Os_Userapp.c:Mismatch in Specification Minor Version"
#endif

/*=======[T A S K S]==========================================*/
/* PRQA S 1532++ */ /* MISRA Rule 8.7 */

/*OsTask_Init: Core0(CPU0),Type = BASIC, Priority = 1*/
uint8_t Private_Key_Test3[32] = {
    0x59,0xA4,0x08,0xB5,0xED,0x69,0xE2,0xEB,
    0xE8,0xDC,0x3D,0xD4,0x62,0x14,0x53,0xDA,
    0x8B,0x0D,0xEB,0xF2,0x94,0x19,0x0A,0xCD,
    0x9C,0xDB,0x45,0x2E,0x90,0xB7,0x76,0x3D,
};
uint8_t Publickey_Test3[64] = {
    0x2E,0xB5,0x01,0x93,0x34,0xA2,0x1A,0xE6,
    0x18,0x57,0x00,0x09,0x49,0x1C,0x50,0xB3,
    0xC1,0x7D,0x6E,0x6B,0x6B,0x9C,0xDE,0xAF,
    0x7E,0x92,0x4B,0x50,0x04,0x85,0x22,0x52,
    0xCE,0x93,0xDF,0x59,0xCF,0xB6,0x07,0xB4,
    0xED,0x46,0xA6,0x54,0x34,0x1F,0x46,0x36,
    0xC1,0x23,0x33,0xC3,0xFA,0x13,0xE2,0x8F,
    0x5B,0x74,0x04,0xA3,0x0C,0x0A,0xFA,0x84};
TASK(OsTask_Init)
{
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK OsTask_Init >
     */
    /* custom code.... */
    uint32 NVM_USE_InitTIME = 0;
    uint32 INIT_READALL_TIMEOUT = 15000;
    NvM_RequestResultType InitNvMReadAllStatus = NVM_REQ_NOT_OK;

    EcuM_StartupTwo();

    Mem_43_INFLS_Init(NULL_PTR);
    MemAcc_Init(&MemAcc_Config);
    Fee_Init(NULL_PTR);
    NvM_Init(NULL_PTR);

    NvM_ReadAll();
    do
    {
        NVM_USE_InitTIME++;
        NvM_MainFunction();
        Fee_MainFunction();
        MemAcc_MainFunction();
        Mem_43_INFLS_MainFunction();
        NvM_GetErrorStatus(0, &InitNvMReadAllStatus);
        if (INIT_READALL_TIMEOUT < NVM_USE_InitTIME)
            break;
    } while (InitNvMReadAllStatus == NVM_REQ_PENDING);

    Dem_Init(&DemPbCfg);
    EcuM_SetWakeupEvent(EcuMWakeupSource_CAN);
    ComM_RequestComMode(0, COMM_FULL_COMMUNICATION);
    Crypto_Init(NULL_PTR);
    CryIf_Init(NULL_PTR);
    Csm_Init(NULL_PTR);
    Csm_KeyElementSet(0, 0, Private_Key_Test3, 32);
    Csm_KeyElementSet(1, 1, Publickey_Test3, 64);
    Csm_KeySetValid(0);
    Csm_KeySetValid(1);
    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK OsTask_Init >
     */
    if (E_OK != TerminateTask())
    {
        while (1)
        {
            /* dead loop */
        }
    }
}

/*OsTask_1ms: Core0(CPU0),Type = BASIC, Priority = 4*/
TASK(OsTask_1ms)
{
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK OsTask_1ms >
     */
    /* custom code.... */
    CanSM_MainFunction();
    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK OsTask_1ms >
     */
    if (E_OK != TerminateTask())
    {
        while (1)
        {
            /* dead loop */
        }
    }
}

/*OsTask_5ms: Core0(CPU0),Type = BASIC, Priority = 3*/
TASK(OsTask_5ms)
{
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK OsTask_5ms >
     */
    /* custom code.... */
    CanNm_MainFunction();
    ComM_MainFunction_Channel_CanController_0();
    Com_MainFunctionRx();
    Com_MainFunctionTx();

    CanTp_MainFunction();
    Dcm_MainFunction();
    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK OsTask_5ms >
     */
    if (E_OK != TerminateTask())
    {
        while (1)
        {
            /* dead loop */
        }
    }
}

uint8 data_input[1024] ={
0x7C,
0x93,
0xAA,
0x2C,
0xB2,
0x89,
0xD3,
0x63,
0x94,
0x53,
0xCE,
0x12,
0x40,
0x8F,
0x81,
0x29,
0x53,
0x33,
0x52,
0x8D,
0x04,
0x81,
0x16,
0x3C,
0x76,
0xC9,
0x2C,
0x2E,
0xD5,
0xA2,
0x8F,
0x48,
0x46,
0xE6,
0x3B,
0xC4,
0x6A,
0x17,
0xAD,
0x1F,
0x89,
0x4D,
0x48,
0xF7,
0x1A,
0xDD,
0x66,
0x1C,
0x00,
0x52,
0x9B,
0x96,
0x1C,
0x6D,
0x86,
0xE7,
0xB4,
0xB0,
0xE6,
0x02,
0x46,
0xF0,
0xD8,
0x14,
0x10,
0x07,
0x62,
0xAC,
0xA1,
0x5F,
0x89,
0xC7,
0x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xD1,
0x96,
0xC2,
0xE0,
0x19,
0x20,
0x53,
0xFC,
0x6A,
0x01,
0xEB,
0x37,
0x2E,
0x61,
0xFB,
0xA5,
0xEA,
0xE2,
0x6A,
0x4F,
0x2E,
0x32,
0xD2,
0x95,
0xDA,
0xDF,
0x18,
0x9F,
0xED,
0xD1,
0x4A,
0x1F,
0x03,
0xC5,
0x68,
0xB3,
0xD1,
0x2C,
0x09,
0xE9,
0x27};
uint8 sign_result[72];
uint8 sign_r[32] = {0};
uint8 sign_s[32] = {0};
uint32 data_input_lenth = 1024;

uint8 encrypt_input[64] = {0x96,0x63,0x97,0xa2,0x23,0xd8,0x52,0x1d,0xee,0xc7,0xa9,0xc2,0x56,0xba,0x70,0xb5,0x3e,0x31,0x3f,0xb0,0x56,0xe9,0x62,0xa3,0x57,0x38,0x56,0x1e,0xb5,0xb8,0xf4,0xcc,0x32,0x2c,0x24,0x33,0xc9,0xdd,0xbc,0xc1,0xb3,0xd1,0x3a,0x44,0xa9,0x79,0x80,0x8d,0xb5,0xaf,0xc6,0xb4,0x3b,0xf4,0x3e,0x90,0xfc,0xa3,0xce,0x9f,0x29,0x4f,0xce,0x82};
uint8 encrypt_input_lenth= 64;
uint8 encrypt_output[256] = {0};
uint32 encrypt_output_lenth = 172;
uint8 decrypt_output[64] = {0};
uint32 decrypt_output_lenth = 64;
uint8 count;
/*OsTask_10ms: Core0(CPU0),Type = BASIC, Priority = 2*/
TASK(OsTask_10ms)
{
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK OsTask_10ms >
     */

    /* custom code.... */
    EcuM_MainFunction();
    BswM_MainFunction();

    Dem_MainFunction();

    NvM_MainFunction();
    Fee_MainFunction();
    MemAcc_MainFunction();
    Mem_43_INFLS_MainFunction();

    Crypto_MainFunction();
    Csm_MainFunction();

    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK OsTask_10ms >
     */
    if (E_OK != TerminateTask())
    {
        while (1)
        {
            /* dead loop */
        }
    }
}

/*OsTask_100ms: Core0(CPU0),Type = BASIC, Priority = 1*/
TASK(OsTask_100ms)
{
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK OsTask_100ms >
     */
    /* custom code.... */
    uint32 sign_result_lenth = 72;
    Std_ReturnType verify_result = CRYPTO_E_VER_NOT_OK;
    Std_ReturnType ret;
   // WdgM_CheckpointReached(WdgMSupervisedEntity_0, SE0_WdgMCheckpoint_0);
   // WdgM_MainFunction();
    count ++;
    if (count % 2 == 0)
    {
        ret = Csm_SignatureGenerate(CsmJob_sign, CRYPTO_OPERATIONMODE_SINGLECALL, data_input, data_input_lenth, sign_result, &sign_result_lenth);
        if (ret == E_OK)
        {
            ret = Csm_SignatureVerify(CsmJob_verify, CRYPTO_OPERATIONMODE_SINGLECALL, data_input, data_input_lenth, sign_result, sign_result_lenth, &verify_result);
            if (ret == E_OK)
            {
                sign_result[6] = sign_result[16];
                sign_result[8] = sign_result[18];
                ret = Csm_SignatureVerify(CsmJob_verify, CRYPTO_OPERATIONMODE_SINGLECALL, data_input, data_input_lenth, sign_result, sign_result_lenth, &verify_result);
                if (ret == E_OK)
                {
                    while (1)
                        ;
                }
            }
            else
            {
                while (1)
                    ;
            }
        }
    }
    else
    {
            peace_sm2_KEY key;

	for (int i = 0; i < 32; i++)
	{
		key.private_key[i] = Private_Key_Test3[i];
		key.public_key.x[i] = Publickey_Test3[i];
		key.public_key.y[i] = Publickey_Test3[i + 32];
	}
       // ret = Csm_Encrypt(CsmJob_encrypt, CRYPTO_OPERATIONMODE_SINGLECALL, encrypt_input, encrypt_input_lenth, encrypt_output, &encrypt_output_lenth);
        ret = peace_sm2_encrypt( &key, encrypt_input, encrypt_input_lenth, encrypt_output, &encrypt_output_lenth);
        if (ret == E_OK)
        {
            //ret = Csm_Decrypt(CsmJob_decrypt, CRYPTO_OPERATIONMODE_SINGLECALL, encrypt_output, encrypt_output_lenth, decrypt_output, &decrypt_output_lenth);
            ret = peace_sm2_decrypt(&key, encrypt_output,  encrypt_output_lenth, decrypt_output, &decrypt_output_lenth);
        }
    }

    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK OsTask_100ms >
     */
    if (E_OK != TerminateTask())
    {
        while (1)
        {
            /* dead loop */
        }
    }
}

/*=======[H O O K S]================================================*/
FUNC(void, OS_APPL_CODE)
IdleHook_Core0(void)
{
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK IdleHook_Core0>
     */
    /* custom code.... */
    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK IdleHook_Core0>
     */
}

/*=======[ALARM CALL BACK]==========================================*/

FUNC(void, OS_APPL_CODE)
ErrorHook(StatusType Error)
{
    /***The code below is just for deleting the complier warning.***
    ***Please remove it and use your own code****/
    (void)Error;
    /***The code above is just for deleting the complier warning*/
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK ErrorHook>
     */
    /* custom code.... */
    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK ErrorHook>
     */
}

FUNC(void, OS_APPL_CODE)
StartupHook(void)
{
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK StartupHook>
     */
    /* custom code.... */
    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK StartupHook>
     */
}

FUNC(void, OS_APPL_CODE)
ShutdownHook(StatusType Error)
{
    /***The code below is just for deleting the complier warning.***
    ***Please remove it and use your own code****/
    (void)Error;
    /***The code above is just for deleting the complier warning*/
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK ShutdownHook>
     */
    /* custom code.... */
    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK ShutdownHook>
     */
}

/*=======[P A N I C H A N D L E R]================================*/
FUNC(void, OS_CODE)
Arch_PanicHandler(void)
{
    /* please insert your code here ... */
}

/*=======[I S R S]================================================*/
/*
 *ISR(CAN0_ORed: Core0(CPU0))
 */
ISR(CAN0_ORed)
{
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK CAN0_ORed>
     */
    /* custom code.... */
    extern void CAN0_ORED_IRQHandler();
    CAN0_ORED_IRQHandler();
    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK CAN0_ORed>
     */
}

/*
 *ISR(CAN0_ORed_0_15_MB: Core0(CPU0))
 */
ISR(CAN0_ORed_0_15_MB)
{
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK CAN0_ORed_0_15_MB>
     */
    /* custom code.... */
    extern void CAN0_ORED_0_15_MB_IRQHandler();
    CAN0_ORED_0_15_MB_IRQHandler();
    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK CAN0_ORed_0_15_MB>
     */
}

/*
 *ISR(CAN0_ORed_16_31_MB: Core0(CPU0))
 */
ISR(CAN0_ORed_16_31_MB)
{
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK CAN0_ORed_16_31_MB>
     */
    /* custom code.... */
    extern void CAN0_ORED_16_31_MB_IRQHandler();
    CAN0_ORED_16_31_MB_IRQHandler();
    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK CAN0_ORed_16_31_MB>
     */
}

/*
 *ISR(FTM0_Ch0_Ch1: Core0(CPU0))
 */
ISR(FTM0_Ch0_Ch1)
{
    /* please insert your code here ... */
    /** DO NOT CHANGE THIS COMMENT!
     * <USERBLOCK FTM0_Ch0_Ch1>
     */
    /* custom code.... */
    extern void FTM_0_CH_0_CH_1_ISR();
    FTM_0_CH_0_CH_1_ISR();
    /** DO NOT CHANGE THIS COMMENT!
     * </USERBLOCK FTM0_Ch0_Ch1>
     */
}

/* PRQA S 1532-- */ /* MISRA Rule 8.7 */
/*=======[E N D   O F   F I L E]==============================================*/
